name: Release QA - OS Matrix - Install from source



on:
  workflow_dispatch:

  release:
    types: [published]

  push:
    branches:
      - add-release-qa-os-matrix-install-from-source



jobs:
  release-qa-os-matrix-install-from-source:

    name: Install on ${{matrix.container}}
    runs-on: ubuntu-20.04



    ### Define the list of container images
    #
    container: ${{ matrix.container }}
    strategy:
      matrix:
        container:
#          - alpine:3.14
#          - alpine:3.15
#          - alpine:3.16

          - archlinux:base-devel

          - almalinux/8-base:latest
          - almalinux/9-base:latest

          - quay.io/centos/centos:stream8
          - quay.io/centos/centos:stream9

          - debian:buster
          - debian:bullseye
          - debian:bookworm
          - debian:sid

          - opensuse/leap:15.4
          - opensuse/leap:15.5
          - opensuse/tumbleweed:latest

          - ubuntu:20.04
          - ubuntu:22.04
          - ubuntu:rolling



    ###
    ### Steps to run
    ###
    steps:



      ### Install prerequisites
      #

      # Alpine
      - run: apk add wget tar gzip bash
        if: ${{ startsWith(matrix.container, 'alpine:') }}

      # Arch
      - run: pacman -Syu --noconfirm   wget tar gzip
        if: ${{ startsWith(matrix.container, 'archlinux:') }}

      # CentOS
      - run: yum install -y   wget tar gzip
        if: ${{ startsWith(matrix.container, 'almalinux/') || startsWith(matrix.container, 'quay.io/centos/centos:') }}

      # Debian / Ubuntu
      - run: |
          DEBIAN_FRONTEND=noninteractive apt-get update -y
          DEBIAN_FRONTEND=noninteractive apt-get install -y   wget tar gzip
        if: ${{ startsWith(matrix.container, 'ubuntu:') || startsWith(matrix.container, 'debian:') }}

      # OpenSUSE
      - run: zypper -n install   wget tar gzip
        if: ${{ startsWith(matrix.container, 'opensuse/') }}



      ### Fetch the code
      #
      # This one is only needed to get that `extract-...` script.
      # NOTICE: For SUSE, make sure to install tar+gzip before running this action
      #
      - uses: actions/checkout@v2

      # Work around the fix for CVE-2022-24765
      - run: git config --global --add safe.directory $GITHUB_WORKSPACE || true



      ### Install
      #
      # The '-r' switch ensures README.md content is pulled from https://github.com/a2o/snoopy
      #
      - run: ./dev-tools/libexec/extract-and-run-install-steps-from-readme.sh -r



      ### Verify Snoopy operation
      #
      - name: Verify Snoopy operation
        run: |
          touch /var/log/snoopy.log
          echo "output = file:/var/log/snoopy.log" >> /etc/snoopy.ini
          /bin/echo "Snoopy is alive and well"
          cat /var/log/snoopy.log | grep -v ': grep' | grep "Snoopy is alive and well"
